package Collection.set;

import org.junit.Test;

import java.util.HashSet;
import java.util.Set;

public class Test_Set {
    //为什么要重写equals还要重写hashcode方法
    @Test
    public void method1(){
        HashSet<Person_Set> person_sets = new HashSet<>();
        Person_Set p1 = new Person_Set(1, "张三");
        Person_Set p2 = new Person_Set(1, "张三");
        System.out.println(p1.equals(p2));
        System.out.println(p1.hashCode()+"---"+p2.hashCode());
        person_sets.add(p1);
        person_sets.add(p2);
        for (Person_Set person_set:person_sets){
            System.out.println(person_set);
        }
    }

}
